<?php
/* 
* @Title:  [商品的视图模型]
* @Author: {chenlei} [chenleib5@126.com]
* @Date:   2014-04-08 11:46:49
* @Last Modified by:   Administrator
* @Last Modified time: 2014-04-09 10:52:51
* @Copyright:  [hn7m.com]
*/
class GoodsViewModel extends ViewModel{
	public $table='goods';  //定义主表

	public $view=array(
		//从表一:商品类型表
		'type' 			=>array(
						'type'	=>INNER_JOIN,
						'on'	=>'type.tid=goods.qm_type_tid'	
			),
		//从表二:商品详情表
		'goods_details' =>array(
						'type'	=>INNER_JOIN,
						'on'	=>'goods.gid=goods_details.qm_goods_gid'
			)
	);  //定义从表
	/**
	 * [get_data 获得所有的数据]
	 * @return [type] [description]
	 */
	public function get_data(){
		return $this->findAll();
	}
	/**
	 * [get_onedate_value 获得某个字段值]
	 * @param  [type] $gid  [description]
	 * @param  [type] $need [description]
	 * @return [type]       [description]
	 */
	public function get_onedate_value($gid,$need){
		return $this->where(array('gid'=>$gid))->getField($need);
	}
	/**
	 * [get_one_data 获得一条数据]
	 * @param  [type] $gid [description]
	 * @return [type]      [description]
	 */
	public function get_one_data($gid){
		return $this->where(array('gid'=>$gid))->find();
	}
}
?>